package app.ui.panels {
	import app.Main;
	import flash.events.Event;

	import com.bit101.components.ComboBox;
	import com.greensock.TweenMax;
	import com.bit101.components.PushButton;
	import com.bit101.components.Label;

	import flash.display.DisplayObjectContainer;

	/**
	 * @author Rendall
	 */
	public class OptionsPanel extends AbstractBrowserPanel {
		public static const STATE_CLOSE_PRESS : String = "STATE_CLOSE_PRESS";
		public static const STATE_SORT_SELECT : String = "STATE_SORT_SELECT";
		
		private var panelTitleLabel : Label;
		private var closeButton : PushButton;
		private var sortOption : ComboBox;

		public function OptionsPanel(parent : DisplayObjectContainer = null, xpos : Number = 0, ypos : Number = 0) {
			super(parent, xpos, ypos);
			setUI();
		}

		private function setUI() : void {
			this.setSize(550, 400);
			y = 400;
			
			setTitle("OPTIONS");
			
			sortOption = new ComboBox(this, 5, 40, "Sort by:", Main.SORT_OPTIONS);
			sortOption.numVisibleItems = Math.min(5,sortOption.items.length);
			sortOption.addEventListener(Event.SELECT, onSortSelect);
			
			

			
			closeButton = new PushButton(this, 5, 5, "CLOSE", onClosePress);
			closeButton.x = 550 - closeButton.width - 5;
		}

		private function onSortSelect(event : Event) : void {
			stateChangeSignal.dispatch(STATE_SORT_SELECT, sortOption.selectedIndex);
		}

		override public function show(option : * = null) : void {
			TweenMax.to(this, 0.5, {y:0});
		}

		override public function hide(option : * = null) : void {
			TweenMax.to(this, 0.25, {y:400});
		}

		private function onClosePress(evt : * = null) : void {
			stateChangeSignal.dispatch(STATE_CLOSE_PRESS);
		}
	}
}
